package com.y.service.impl;

import com.github.pagehelper.PageHelper;
import com.y.mapper.HouseMapper;
import com.y.pojo.House;
import com.y.service.IHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HouseService implements IHouseService {
    @Autowired
    private HouseMapper houseMapper;
    @Override
    public int insertHouse(House house) throws Exception {
        return houseMapper.insertHouse(house);
    }

    @Override
    public List<House> queryHouse(int pid) throws Exception {
        return houseMapper.queryHouse(pid);
    }

    @Override
    public int delHouse(int hid) throws Exception {
        return houseMapper.delHouse(hid);
    }

    @Override
    public int updateHouse(House house) throws Exception {
        return houseMapper.updateHouse(house);
    }

    @Override
    public House selHouse(int hid) throws Exception {
        return houseMapper.selHouse(hid);
    }

    @Override
    public List<House> queHouse() throws Exception {
        return houseMapper.queHouse();
    }

    @Override
    public List<House> getAllHouse(int currPage, int pageSize){

        //分页
        PageHelper.startPage(currPage,pageSize);  //自动修改sql语句
        List<House> list=null;
        try {
        list = houseMapper.seHouse();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    @Override
    public int getCount() throws Exception {
        return houseMapper.selAllCount();
    }

    @Override
    public List<House> quHouse(String str1) throws Exception {
        return houseMapper.quHouse(str1);
    }

    @Override
    public List<House> delete(int pid) throws Exception {
        return houseMapper.delete(pid);
    }
}
